import request from '@/utils/request'
// import qs from 'qs'

// 报表任务

// 创建报表任务
export function addReport (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/addReport',
    method: 'post',
    data
  })
}

// 创建报表任务
export function editReport (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/editReport',
    method: 'post',
    data
  })
}

// 删除报表任务
export function delReportInfo (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/delReportInfo',
    method: 'post',
    data
  })
}

// 清空报表任务
export function clearReport (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/clearReport',
    method: 'post',
    data
  })
}

// 获取报表任务信息
export function getReportInfo (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/getReportInfo',
    method: 'post',
    data
  })
}

// 获取报表任务列表
export function getReportArray (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/getReportArray',
    method: 'post',
    data
  })
}

// 设置报表任务状态
export function setReportStatus (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/setReportStatus',
    method: 'post',
    data
  })
}

// 获取报表任务数据报表列表
export function getReportDownloadArray (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/getReportDownloadArray',
    method: 'post',
    data
  })
}

// 下载报表任务数据报表文件
export function downloadReportDownload (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/downloadReportDownload',
    method: 'post',
    data
  })
}

// 创建报表任务数据报表
export function getReportData (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/getReportData',
    method: 'post',
    data
  })
}

// 删除报表任务数据报表
export function delReportDownload (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/delReportDownload',
    method: 'post',
    data
  })
}

// 清空报表任务数据报表
export function clearReportDownload (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/clearReportDownload',
    method: 'post',
    data
  })
}

// 获取报表任务数据报表信息
export function getReportDownloadInfo (params) {
  var data = fromData(params)
  return request({
    url: '/report_log/getReportDownloadInfo',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
